#include <iostream>
#include <string>
#include<cstring>
using namespace std;
class Cow {
private:
char name[20];
char *hobby;
double weight;

public:
//默认构造函数
Cow() : weight(0)
  {name[0] = '\0' ;hobby = nullptr;}

//传参数的构造函数
Cow(const char * nm, const char * ho, double wt) : weight(wt) {
  strncpy(name,nm,19);
  name[19] = '\0';
  hobby = new char[strlen(ho) + 1];
  strcpy(hobby, ho);
};
//复制构造函数
Cow(const Cow &c) : weight(c.weight){
  strcpy(name,c.name);
  hobby =  new char[strlen(c.hobby) + 1];
  strcpy(hobby,c.hobby);
};
//析构函数
~Cow() {
delete [] hobby;
};
//重载赋值函数
Cow & operator=(const Cow & c)  {
  weight = c.weight;
  strcpy(name,c.name);
  hobby =  new char[strlen(c.hobby) + 1];
  strcpy(hobby,c.hobby);
  return *this;
}

void ShowCow() const
{
  cout << name << " "<< hobby << " " << weight << endl;
}
};

int main(){
char *name = new char[20];
char *hobby = new char[30];
double weight;
cin.getline(name,20);
cin.getline(hobby,30);
cin >> weight;
Cow cow1(name,hobby,weight);
cin.ignore();
cin.getline(name,20);
cin.getline(hobby,30);
cin >> weight;
Cow cow2(name,hobby,weight);
Cow cow3 = cow1;
Cow cow4;
cow4 = cow2;
cow3.ShowCow();
cow4.ShowCow();
return 0;
}

